package com.sec.bnjey.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DtcDbHelper extends SQLiteOpenHelper {

	static final String DATABASE_NAME = "dtc_info.db";
	static final String DATABASE_TABLE = "dtcinfo";
	static final int DATABASE_VERSION = 1;

	public static final String PKEY = "PKEY"; // primary key
	public static final String CODE = "CODE"; // dtc code
	public static final String INFO_ENG = "INFO_ENG"; // detail info about dtc
														// code in English
	public static final String INFO_KOR = "INFO_KOR"; // detail info about dtc
														// code in Korean
	public static final String SUB_INFO_KOR = "SUB_INFO_KOR"; // sub detail info
																// about dtc
																// code in
																// Korean

	private static final String createQuery = "CREATE TABLE " + DATABASE_TABLE
			+ " (PKEY INTEGER PRIMARY KEY AUTOINCREMENT, " + CODE + " TEXT, "
			+ INFO_ENG + " TEXT, " + INFO_KOR + " TEXT, " + SUB_INFO_KOR
			+ " TEXT" + ")";

	public DtcDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(createQuery);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
		onCreate(db);
	}

}
